package com.document;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.Toast;

public class ViewFileImg extends Activity {
	private ImageView ImgView;
	private String filepath;
    private Bitmap bm;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 final Activity activity = this;
		getWindow().requestFeature(Window.FEATURE_PROGRESS);  		         
        // 取消掉状态栏  完成窗体的全屏显示
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                WindowManager.LayoutParams.FLAG_FULLSCREEN); 
		setContentView(R.layout.image);
		ImgView=(ImageView)findViewById(R.id.image);
		final String path = GetPath.getpath()+File.separator;
		 Intent i=getIntent();
         Uri uri=(Uri)i.getData();
         filepath=uri.getPath(); 
          bm=new BitmapFactory().decodeFile(filepath);
         ImgView.setImageBitmap(bm);
       
}
	//添加菜单
	 public boolean onCreateOptionsMenu(Menu menu)    
	    {    
	            
	        menu.add(0, 0, 0, "截屏");  
	        menu.add(0, 1, 0, "发送");  	                	          
	        return super.onCreateOptionsMenu(menu);    
	    }    	    	 
	    @Override    
	    public boolean onOptionsItemSelected(MenuItem item)    
	    {    
	        switch(item.getItemId())    
	        {    
	            case 0:   
	                {   
	                	SimpleDateFormat formatter=new SimpleDateFormat("MM月dd日HH.mm.ss");       
	                	Date curDate=new Date(System.currentTimeMillis());//获取当前时间       
	                	String str=formatter.format(curDate);
	                	System.out.println(str);
	               	 ShotView.shot(this,"mnt/sdcard/DCIM/Img截图"+str+".png");
	                  
            Toast.makeText(getApplicationContext(), "截屏成功,已保存在mnt/sdcard/DCIM/Word截图"+str+".png", Toast.LENGTH_LONG).show();
            
	                    break;    
	                }  
	            case 1:   
               {   
            	 //调用邮件
		    		startActivity(getFileIntent.getmainIntent(filepath));
		    		break;                             
               } 
	        }
			return false;}

	    }
